Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

About Draw Context Objects

The QuickDraw 3D graphics library is able to direct its output--a rendered image--into one or more destinations (hereafter called its drawing destinations ). For instance, you can use QuickDraw 3D to draw three-dimensional images into a standard Mac OS window.To achieve this cross-platform drawing capability, and thereby to insulate most of the application programming interfaces from details of the underlying drawing destination, QuickDraw 3D uses objects called draw context objects. A draw context object (or, more briefly, a draw context ) is a QuickDraw 3D object that maintains information specific to a particular window system or drawing destination.

In general, QuickDraw 3D does not duplicate existing methods of creating, handling user actions in, or manipulating drawing destinations. For example, QuickDraw 3D does not provide any means of creating a Mac OS window, handling events in the window, or modifying the size or location of the window. A QuickDraw 3D draw context, which provides a link between your application and the Mac OS window, simply contains the minimum amount of information it needs to draw into the window. You must use the Window Manager for all other operations on a Mac OS window.

A draw context is of type TQ3DrawContextObject , which is a subtype of shared object. You need to create an instance of a specific type of draw context object and then attach it to a view, usually by calling Q3View_SetDrawContext . QuickDraw 3D currently supports these types of draw contexts:

Not all drawing destinations are windows. QuickDraw 3D supports the pixmap draw context for drawing an image into an arbitrary region of memory (that is, a pixmap). You can, if necessary, even create instances of several kinds of draw contexts and draw the same scene into several different kinds of windows.

All draw contexts share a set of basic properties, which are maintained in a structure of type TQ3DrawContextData .

typedef struct TQ3DrawContextData {
    TQ3DrawContextClearImageMethod                  clearImageMethod;
    TQ3ColorARGB                                    clearImageColor;
    TQ3Area                                         pane;
    TQ3Boolean                                      paneState;
    TQ3Bitmap                                       mask;
    TQ3Boolean                                      maskState;
    TQ3Boolean                                      doubleBufferState;
} TQ3DrawContextData;

Windows 32 draw contexts are always implicitly double buffered and Direct Draw surface draw contexts are single buffered, regardless of the value of doubleBufferState.

The TQ3DrawContextData fields define the manner in which a window (or region of memory) is cleared, the size of the destination drawing pane, the drawing mask, and the state of the double buffering. These basic properties are designed to be independent of any particular window system. You can rely on the capabilities provided by these properties across window systems, whether or not the drawing destination supports them.

Not all the basic properties maintained in the TQ3DrawContextData data structure are supported by all draw contexts. For example, it makes no sense to use double buffering when drawing into a pixmap.

In addition to these basic properties that are common to all draw contexts, each specific type of draw context defines context-specific properties. For example, the Macintosh draw context maintains information about the window into which QuickDraw 3D is to draw, the optional use of a two-dimensional graphics library (QuickDraw or QuickDraw GX), and so forth. The following sections describe the specific draw context types.

Macintosh Draw Contexts

Pixmap Draw Contexts

Windows Draw Contexts


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |